<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>example/c/candb_sample.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="kvaser.gif"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('example_2c_2candb_sample_8c-example.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">example/c/candb_sample.c</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">** This software is furnished as Redistributable under the Kvaser Software Licence</span></div><div class="line"><span class="comment">** https://www.kvaser.com/canlib-webhelp/page_license_and_copyright.html</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">** Description:</span></div><div class="line"><span class="comment">** This is a sample console program that uses CANDB to create and access CAN</span></div><div class="line"><span class="comment">** databases. It creates a database file named &#39;temp.dbc&#39; in the directory</span></div><div class="line"><span class="comment">** where it is invoked.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">** The program is just intended as an example of how to use CANDB. It&#39;s not</span></div><div class="line"><span class="comment">** performance optimized in any way. It may, or may not, be useful for you.</span></div><div class="line"><span class="comment">*/</span></div><div class="line"></div><div class="line"><span class="preprocessor">#if !LINUX</span></div><div class="line"><span class="preprocessor">#include &lt;windows.h&gt;</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div><div class="line"></div><div class="line"><span class="comment">// CANDB requires the following #include.</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="kva_db_lib_8h.html">kvaDbLib.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// Forward declarations</span></div><div class="line"><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> createNewDatabase(<span class="keywordtype">char</span> *filename);</div><div class="line"><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> dumpDatabase(<span class="keywordtype">char</span> *filename);</div><div class="line"><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> editDatabase(<span class="keywordtype">char</span> *filename);</div><div class="line"></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="comment">// Main</span></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> status;</div><div class="line">  <span class="keywordtype">char</span> filename[] = <span class="stringliteral">&quot;temp.dbc&quot;</span>;</div><div class="line"></div><div class="line">  printf(<span class="stringliteral">&quot;\nSample program for the CANdb-API DLL:\n\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// Create a new database from scratch</span></div><div class="line">  printf(<span class="stringliteral">&quot;1. Create a new data base with two messages and three signals...&quot;</span>);</div><div class="line">  status = createNewDatabase(filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a name="a0"></a><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;\nError: Could not create a new database: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">  }</div><div class="line">  printf(<span class="stringliteral">&quot;done.\n\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// Dump the contents of the database to stdout</span></div><div class="line">  printf(<span class="stringliteral">&quot;2. Display the contents of the database:\n&quot;</span>);</div><div class="line">  status = dumpDatabase(filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;\nError: Could not dump the contents of the database: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">  }</div><div class="line"></div><div class="line">  printf(<span class="stringliteral">&quot;3. Remove the first message and change a signal in the second...&quot;</span>);</div><div class="line">  <span class="comment">// Edit the new database</span></div><div class="line">  status = editDatabase(filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;\nError: Could not edit a new database: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">  }</div><div class="line">  printf(<span class="stringliteral">&quot;done.\n\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// Dump the contents of the updated database to stdout</span></div><div class="line">  printf(<span class="stringliteral">&quot;4. Display the contents of the edited database:\n&quot;</span>);</div><div class="line">  status = dumpDatabase(filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;\nError: Could not dump the contents of the updated database: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">  }</div><div class="line"></div><div class="line">  printf(<span class="stringliteral">&quot;\nDone.\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="comment">// Convert signal encoding to a string</span></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span>* sigEncToStr(<a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4">KvaDbSignalEncoding</a> sigEnc)</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (sigEnc == <a name="a1"></a><a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4a986b67715a2013d6e8b60e633220d549">kvaDb_Intel</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Intel&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sigEnc == <a name="a2"></a><a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4ae6404dfa913ebc8ce715aed16d47816e">kvaDb_Motorola</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Motorola&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Undefined&quot;</span>;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="comment">// Convert signal representation to a string</span></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span>* sigRepToStr(<a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270">KvaDbSignalType</a> sigType)</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (sigType == <a name="a3"></a><a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270ab777a64c513802d7af5ff4024fcce7e2">kvaDb_Invalid</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Invalid&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sigType == <a name="a4"></a><a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270aa0719be54ca22ada83d9eeb867c63787">kvaDb_Signed</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Signed&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sigType == <a name="a5"></a><a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270af1ca5045071de9e05d80d2c7b2975ae0">kvaDb_Unsigned</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Unsigned&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sigType == <a name="a6"></a><a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270acc006914e40331c093e3278e0354d556">kvaDb_Float</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Float&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sigType == <a name="a7"></a><a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270a8b1b494e1c72070d3e624ef9e0f62347">kvaDb_Double</a>) {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Double&quot;</span>;</div><div class="line">  } <span class="keywordflow">else</span> {</div><div class="line">    <span class="keywordflow">return</span> <span class="stringliteral">&quot;Undefined&quot;</span>;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// Create a new database with two messages and three signals</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> createNewDatabase (<span class="keywordtype">char</span> *filename) {</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> status;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a0ab6b252bb2dbf1312bd48208954e67b">KvaDbHnd</a> dh;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a561c9270625ed9b7a4bc32edaab72227">KvaDbMessageHnd</a> mh;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#aa41cb518eea5c637f18eda0affa4e011">KvaDbSignalHnd</a> sh;</div><div class="line"></div><div class="line">  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data[8];</div><div class="line">  <span class="keywordtype">int</span> dlc = 8;</div><div class="line">  <span class="keywordtype">int</span> t_raw = 0;</div><div class="line">  <span class="keywordtype">double</span> t_phys = 0;</div><div class="line">  memset(data, 0, <span class="keyword">sizeof</span>(data));</div><div class="line"></div><div class="line">  <span class="comment">// Open a database handle</span></div><div class="line">  status = <a name="a8"></a><a class="code" href="group__kvadb__database.html#gacbcd92e8da46f1b756c72d25ab92d240">kvaDbOpen</a>(&amp;dh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf (<span class="stringliteral">&quot;kvaDbOpen falied: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Create a new empty database</span></div><div class="line">  status = <a name="a9"></a><a class="code" href="group__kvadb__database.html#ga0da72bb21d2664d6443f7b3349ec9df5">kvaDbCreate</a>(dh, <span class="stringliteral">&quot;T-base&quot;</span>, NULL);</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf (<span class="stringliteral">&quot;kvaDbCreate failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Add a new message to the database</span></div><div class="line">  <span class="comment">// ---------------------------------</span></div><div class="line">  status = <a name="a10"></a><a class="code" href="group__kvadb__messages.html#ga20409dc07a8fa5f38cfd2e54f98e5748">kvaDbAddMsg</a>(dh, &amp;mh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbAddMsg failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message properties</span></div><div class="line">  status = <a name="a11"></a><a class="code" href="group__kvadb__messages.html#gab0420983b735501899087eef7b127ccd">kvaDbSetMsgName</a>(mh, <span class="stringliteral">&quot;TempMessage01&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgName failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message id</span></div><div class="line">  status = <a name="a12"></a><a class="code" href="group__kvadb__messages.html#ga6b607012a7889df9b00f032aee6959ff">kvaDbSetMsgId</a>(mh, 340, 0);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgId failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message comment</span></div><div class="line">  status = <a name="a13"></a><a class="code" href="group__kvadb__messages.html#ga6a9bd277edbb0617de75553dd9aa21fa">kvaDbSetMsgComment</a>(mh, <span class="stringliteral">&quot;Temperature message 02.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgComment failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message dlc</span></div><div class="line">  status = <a name="a14"></a><a class="code" href="group__kvadb__messages.html#ga4adb841c585acfacdb73c5836a7c5b7d">kvaDbSetMsgDlc</a>(mh, dlc);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgDlc failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Add a signal to the new message</span></div><div class="line">  <span class="comment">// -------------------------------</span></div><div class="line">  status = <a name="a15"></a><a class="code" href="group__kvadb__signals.html#gabbbad3a12d611acbd969734481fcc48c">kvaDbAddSignal</a>(mh, &amp;sh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbAddSignal failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal name</span></div><div class="line">  status = <a name="a16"></a><a class="code" href="group__kvadb__signals.html#ga43c3ac08f5a5114b1495b073d285df06">kvaDbSetSignalName</a>(sh, <span class="stringliteral">&quot;Status&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalName failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal comment</span></div><div class="line">  status = <a name="a17"></a><a class="code" href="group__kvadb__signals.html#ga124f0345c198a4f2c5a79c1620fba6a7">kvaDbSetSignalComment</a>(sh,<span class="stringliteral">&quot;The status signal.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalComment failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal unit</span></div><div class="line">  status = <a name="a18"></a><a class="code" href="group__kvadb__signals.html#gabf8723b14dafc4597cd68d72a0608884">kvaDbSetSignalUnit</a>(sh, <span class="stringliteral">&quot;-&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalUnit failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal encoding</span></div><div class="line">  status = <a name="a19"></a><a class="code" href="group__kvadb__signals.html#ga692bc09e34328197d5061cdb521c6c3f">kvaDbSetSignalEncoding</a>(sh, <a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4a986b67715a2013d6e8b60e633220d549">kvaDb_Intel</a>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalEncoding failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal representation</span></div><div class="line">  status = <a name="a20"></a><a class="code" href="group__kvadb__signals.html#gab9a22491498bd216717e9edf627b694d">kvaDbSetSignalRepresentationType</a>(sh, <a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270af1ca5045071de9e05d80d2c7b2975ae0">kvaDb_Unsigned</a>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalRepresentationType failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal value limits</span></div><div class="line">  status = <a name="a21"></a><a class="code" href="group__kvadb__signals.html#ga3bfdb0480993002989f6f73b84768f9c">kvaDbSetSignalValueLimits</a>(sh, 0, 0xFFFFFFFF);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueLimits failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal value size</span></div><div class="line">  status = <a name="a22"></a><a class="code" href="group__kvadb__signals.html#ga734770b9b425260f1f9bb4dc5a886aaf">kvaDbSetSignalValueSize</a>(sh, 0, 32);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueSize failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// Add a second message with two signals to the database</span></div><div class="line">  <span class="comment">// -----------------------------------------------------</span></div><div class="line">  status = <a class="code" href="group__kvadb__messages.html#ga20409dc07a8fa5f38cfd2e54f98e5748">kvaDbAddMsg</a>(dh, &amp;mh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbAddMsg failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message name</span></div><div class="line">  status = <a class="code" href="group__kvadb__messages.html#gab0420983b735501899087eef7b127ccd">kvaDbSetMsgName</a>(mh, <span class="stringliteral">&quot;TempMessage02&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgName failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message id</span></div><div class="line">  status = <a class="code" href="group__kvadb__messages.html#ga6b607012a7889df9b00f032aee6959ff">kvaDbSetMsgId</a>(mh, 345, 0);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgId failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message comment</span></div><div class="line">  status = <a class="code" href="group__kvadb__messages.html#ga6a9bd277edbb0617de75553dd9aa21fa">kvaDbSetMsgComment</a>(mh, <span class="stringliteral">&quot;Temperature message 01.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgComment failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set the message dlc</span></div><div class="line">  status = <a class="code" href="group__kvadb__messages.html#ga4adb841c585acfacdb73c5836a7c5b7d">kvaDbSetMsgDlc</a>(mh, dlc);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetMsgDlc failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Add a signal to the second message</span></div><div class="line">  <span class="comment">// ----------------------------------</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gabbbad3a12d611acbd969734481fcc48c">kvaDbAddSignal</a>(mh, &amp;sh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbAddSignal failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal name</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga43c3ac08f5a5114b1495b073d285df06">kvaDbSetSignalName</a>(sh, <span class="stringliteral">&quot;T01&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalName failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal comment</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga124f0345c198a4f2c5a79c1620fba6a7">kvaDbSetSignalComment</a>(sh,<span class="stringliteral">&quot;The first temperature signal.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalComment failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal unit</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gabf8723b14dafc4597cd68d72a0608884">kvaDbSetSignalUnit</a>(sh, <span class="stringliteral">&quot;C&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalUnit failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal encoding</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga692bc09e34328197d5061cdb521c6c3f">kvaDbSetSignalEncoding</a>(sh, <a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4a986b67715a2013d6e8b60e633220d549">kvaDb_Intel</a>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalEncoding failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal representation</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gab9a22491498bd216717e9edf627b694d">kvaDbSetSignalRepresentationType</a>(sh, <a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270aa0719be54ca22ada83d9eeb867c63787">kvaDb_Signed</a>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalRepresentationType failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal value limits</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga3bfdb0480993002989f6f73b84768f9c">kvaDbSetSignalValueLimits</a>(sh, -100, 1000);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueLimits failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal scale factor and offset</span></div><div class="line">  status = <a name="a23"></a><a class="code" href="group__kvadb__signals.html#ga3a01b63f3b3a413d008bdcb85778034f">kvaDbSetSignalValueScaling</a>(sh, 0.02, 10);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueScaling failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal value size</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga734770b9b425260f1f9bb4dc5a886aaf">kvaDbSetSignalValueSize</a>(sh, 0, 32);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueSize failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Add another signal to the second message</span></div><div class="line">  <span class="comment">// ----------------------------------------</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gabbbad3a12d611acbd969734481fcc48c">kvaDbAddSignal</a>(mh, &amp;sh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbAddSignal failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal name</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga43c3ac08f5a5114b1495b073d285df06">kvaDbSetSignalName</a>(sh, <span class="stringliteral">&quot;T02&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalName failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal comment</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga124f0345c198a4f2c5a79c1620fba6a7">kvaDbSetSignalComment</a>(sh,<span class="stringliteral">&quot;The second temperature signal.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalComment failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal unit</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gabf8723b14dafc4597cd68d72a0608884">kvaDbSetSignalUnit</a>(sh, <span class="stringliteral">&quot;C&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalUnit failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal encoding</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga692bc09e34328197d5061cdb521c6c3f">kvaDbSetSignalEncoding</a>(sh, <a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4a986b67715a2013d6e8b60e633220d549">kvaDb_Intel</a>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalEncoding failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal representation</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gab9a22491498bd216717e9edf627b694d">kvaDbSetSignalRepresentationType</a>(sh, <a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270aa0719be54ca22ada83d9eeb867c63787">kvaDb_Signed</a>);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalRepresentationType failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal value limits</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga3bfdb0480993002989f6f73b84768f9c">kvaDbSetSignalValueLimits</a>(sh, -100, 1000);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueLimits failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal scale factor and offset</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga3a01b63f3b3a413d008bdcb85778034f">kvaDbSetSignalValueScaling</a>(sh, 0.01, -10);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueScaling failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Set signal value size</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga734770b9b425260f1f9bb4dc5a886aaf">kvaDbSetSignalValueSize</a>(sh, 31, 32);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbSetSignalValueSize failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Use the signal data conversion functions</span></div><div class="line">  <span class="comment">// ----------------------------------------</span></div><div class="line">  status = <a name="a24"></a><a class="code" href="group__kvadb__signals.html#ga1f735b50e369c784901abc3ea436fba9">kvaDbGetSignalByName</a>(mh, <span class="stringliteral">&quot;T01&quot;</span>, &amp;sh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbGetSignalByName failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Convert the physical temperature value 31.5 to CAN data</span></div><div class="line">  status = <a name="a25"></a><a class="code" href="group__kvadb__signals.html#gab9fcbde5951aacd3daf85f9ea95868a2">kvaDbStoreSignalValuePhys</a>(sh, &amp;data[0], <span class="keyword">sizeof</span>(data), 31.5);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbStoreSignalValuePhys failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Convert the CAN data back to physical value as float</span></div><div class="line">  status = <a name="a26"></a><a class="code" href="group__kvadb__signals.html#gaa55f93eb1866e1786e66be587abf1b6f">kvaDbGetSignalValueFloat</a>(sh, &amp;t_phys, data, <span class="keyword">sizeof</span>(data));</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbGetSignalValueFloat failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Convert the CAN data back to physical value as float</span></div><div class="line">  status = <a name="a27"></a><a class="code" href="group__kvadb__signals.html#ga929e36e4b5b88d6c4db67c50f0b6f9e9">kvaDbGetSignalValueInteger</a>(sh, &amp;t_raw, data, <span class="keyword">sizeof</span>(data));</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbGetSignalValueInteger failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Save the database to file</span></div><div class="line">  status = <a name="a28"></a><a class="code" href="group__kvadb__database.html#gabf1db33bc6778e2f77ab1b66e8f743e9">kvaDbWriteFile</a>(dh, filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbWriteFile failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Close and free allocated memory</span></div><div class="line">  status = <a name="a29"></a><a class="code" href="group__kvadb__database.html#ga08c85db8a33c4dcdb9d1114b72ab7c30">kvaDbClose</a>(dh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbClose failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">return</span> status;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// Dump the contents of a database to stdout</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> dumpDatabase (<span class="keywordtype">char</span> *filename)</div><div class="line">{</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> status;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a0ab6b252bb2dbf1312bd48208954e67b">KvaDbHnd</a> dh = 0;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a561c9270625ed9b7a4bc32edaab72227">KvaDbMessageHnd</a> mh = 0;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#aa41cb518eea5c637f18eda0affa4e011">KvaDbSignalHnd</a> sh = 0;</div><div class="line">  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> flags = 0;</div><div class="line"></div><div class="line">  <span class="comment">// Open a database handle</span></div><div class="line">  status = <a class="code" href="group__kvadb__database.html#gacbcd92e8da46f1b756c72d25ab92d240">kvaDbOpen</a> (&amp;dh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not create a database handle: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Load the database file</span></div><div class="line">  status = <a name="a30"></a><a class="code" href="group__kvadb__database.html#gaadd6d76a4a37fce5dacddc973951e8c8">kvaDbReadFile</a> (dh, filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not load &#39;%s&#39;: %d\n&quot;</span>, filename, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  status = <a name="a31"></a><a class="code" href="group__kvadb__database.html#ga04b35b1f5416157cb633cf7c44df396e">kvaDbGetFlags</a>(dh, &amp;flags);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf (<span class="stringliteral">&quot;kvaDbGetFlags failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line">  printf (<span class="stringliteral">&quot;  Database: flags=0x%x\n&quot;</span>, flags);</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// Get the first message in the database</span></div><div class="line">  status = <a name="a32"></a><a class="code" href="group__kvadb__messages.html#ga860fbe484bbe5722c5141e8d73d51b81">kvaDbGetFirstMsg</a> (dh, &amp;mh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf (<span class="stringliteral">&quot;kvaDbGetFirstMsg failed: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Go through all messages in the database</span></div><div class="line">  <span class="keywordflow">while</span> (status == <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    <span class="keywordtype">char</span> msg_name[100];</div><div class="line">    <span class="keywordtype">char</span> msg_qname[200];</div><div class="line">    <span class="keywordtype">char</span> msg_comment[200];</div><div class="line">    <span class="keywordtype">int</span>  dlc = 0;</div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <span class="keywordtype">id</span> = 0;</div><div class="line"></div><div class="line">    <span class="comment">// Clear the strings</span></div><div class="line">    memset(msg_name,    0, <span class="keyword">sizeof</span>(msg_name));</div><div class="line">    memset(msg_qname,   0, <span class="keyword">sizeof</span>(msg_qname));</div><div class="line">    memset(msg_comment, 0, <span class="keyword">sizeof</span>(msg_comment));</div><div class="line"></div><div class="line">    <span class="comment">// Get the properties for each message</span></div><div class="line">    status = <a name="a33"></a><a class="code" href="group__kvadb__messages.html#ga194badc7e10d889df38a0f4eb763b5e6">kvaDbGetMsgName</a> (mh, msg_name, <span class="keyword">sizeof</span> (msg_name));</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf (<span class="stringliteral">&quot;kvaDbGetMsgName failed: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a name="a34"></a><a class="code" href="group__kvadb__messages.html#gad34b31d9be199e8b7ac2d7d3dcab8f1e">kvaDbGetMsgQualifiedName</a> (mh, msg_qname, <span class="keyword">sizeof</span> (msg_qname));</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf (<span class="stringliteral">&quot;kvaDbGetMsgQualifiedName failed: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a name="a35"></a><a class="code" href="group__kvadb__messages.html#gace75dd206cd50883de777ed1d8051e1b">kvaDbGetMsgComment</a> (mh, msg_comment, <span class="keyword">sizeof</span> (msg_comment));</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf (<span class="stringliteral">&quot;kvaDbGetMsgComment failed: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a name="a36"></a><a class="code" href="group__kvadb__messages.html#gad38351a6992901219de951400c681974">kvaDbGetMsgId</a> (mh, &amp;<span class="keywordtype">id</span>, &amp;flags);</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf (<span class="stringliteral">&quot;kvaDbGetMsgId failed: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a name="a37"></a><a class="code" href="group__kvadb__messages.html#gaad8505adb65a9f91a646951136456404">kvaDbGetMsgDlc</a> (mh, &amp;dlc);</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf (<span class="stringliteral">&quot;kvaDbGetMsgDlc failed: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// Print the properties for each message</span></div><div class="line">    printf (<span class="stringliteral">&quot;    Msg: name=&#39;%s&#39;\n&quot;</span>, msg_name);</div><div class="line">    printf (<span class="stringliteral">&quot;         qname=&#39;%s&#39;, comment=&#39;%s&#39;\n&quot;</span>, msg_qname, msg_comment);</div><div class="line">    printf (<span class="stringliteral">&quot;         id=%x, dlc=%d, flags=%x\n&quot;</span>, <span class="keywordtype">id</span>, dlc, flags);</div><div class="line"></div><div class="line"></div><div class="line">    <span class="comment">// Go through all signals for this message</span></div><div class="line">    status = <a name="a38"></a><a class="code" href="group__kvadb__signals.html#gaeec680d3d20bddb57dd09389faacba9e">kvaDbGetFirstSignal</a> (mh, &amp;sh);</div><div class="line">    <span class="keywordflow">while</span> (status == <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      <span class="keywordtype">char</span> signal_name[100];</div><div class="line">      <span class="keywordtype">char</span> signal_qname[200];</div><div class="line">      <span class="keywordtype">char</span> signal_comment[200];</div><div class="line">      <span class="keywordtype">char</span> signal_unit[100];</div><div class="line">      <a class="code" href="kva_db_lib_8h.html#ad67767865a1ea13724d931f94d6eeee4">KvaDbSignalEncoding</a> sigEnc;</div><div class="line">      <a class="code" href="kva_db_lib_8h.html#aca4f6042ed5df050dab2ff4278fc7270">KvaDbSignalType</a> sigType;</div><div class="line">      <span class="keywordtype">int</span> startbit = 0;</div><div class="line">      <span class="keywordtype">int</span> length = 0;</div><div class="line">      <span class="keywordtype">double</span> minval = 0;</div><div class="line">      <span class="keywordtype">double</span> maxval = 0;</div><div class="line">      <span class="keywordtype">double</span> factor = 0;</div><div class="line">      <span class="keywordtype">double</span> offset = 0;</div><div class="line"></div><div class="line">      <span class="comment">// Reset the strings</span></div><div class="line">      memset(signal_name,    0, <span class="keyword">sizeof</span>(signal_name));</div><div class="line">      memset(signal_qname,   0, <span class="keyword">sizeof</span>(signal_qname));</div><div class="line">      memset(signal_comment, 0, <span class="keyword">sizeof</span>(signal_comment));</div><div class="line">      memset(signal_unit,    0, <span class="keyword">sizeof</span>(signal_unit));</div><div class="line"></div><div class="line">      <span class="comment">// Get the properties for each signal.</span></div><div class="line">      status = <a name="a39"></a><a class="code" href="group__kvadb__signals.html#ga1789980c0ede9307c77ecc265be94539">kvaDbGetSignalName</a> (sh, signal_name, <span class="keyword">sizeof</span> (signal_name));</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalName failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a40"></a><a class="code" href="group__kvadb__signals.html#ga60dabd749ad9113ecff2cf4d6fc4df62">kvaDbGetSignalQualifiedName</a> (sh, signal_qname, <span class="keyword">sizeof</span> (signal_qname));</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalQualifiedName failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a41"></a><a class="code" href="group__kvadb__signals.html#gadd24017befa2f40a86c84792fe176b52">kvaDbGetSignalComment</a> (sh, signal_comment, <span class="keyword">sizeof</span> (signal_comment));</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalComment failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a42"></a><a class="code" href="group__kvadb__signals.html#ga1b531b74cc568105f7ed3fbaefbcb7b4">kvaDbGetSignalUnit</a> (sh, signal_unit, <span class="keyword">sizeof</span> (signal_unit));</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalUnit failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a43"></a><a class="code" href="group__kvadb__signals.html#ga1f399fd6ccee89e0a0c4f5df1324311b">kvaDbGetSignalEncoding</a> (sh, &amp;sigEnc);</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalEncoding failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a44"></a><a class="code" href="group__kvadb__signals.html#ga0bb3a9d21b17499ebd838b9d21114d53">kvaDbGetSignalRepresentationType</a>(sh, &amp;sigType);</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalRepresentationType failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a45"></a><a class="code" href="group__kvadb__signals.html#gac0d9f8909c721b79b0c0e213fc22e607">kvaDbGetSignalValueLimits</a>(sh, &amp;minval, &amp;maxval);</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalValueLimits failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a46"></a><a class="code" href="group__kvadb__signals.html#gac592e48b7618d40d778698a5c21ed14d">kvaDbGetSignalValueScaling</a>(sh, &amp;factor, &amp;offset);</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalValueScaling failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      status = <a name="a47"></a><a class="code" href="group__kvadb__signals.html#ga81ca4318029cefe8ecf5df6e5c237b5e">kvaDbGetSignalValueSize</a>(sh, &amp;startbit, &amp;length);</div><div class="line">      <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">        printf (<span class="stringliteral">&quot;kvaDbGetSignalValueSize failed: %d\n&quot;</span>, status);</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">      }</div><div class="line"></div><div class="line">      printf(<span class="stringliteral">&quot;      Signal: name=&#39;%s&#39;, unit=&#39;%s&#39;\n&quot;</span>, signal_name, signal_unit);</div><div class="line">      printf(<span class="stringliteral">&quot;              qname=&#39;%s&#39;\n&quot;</span>, signal_qname);</div><div class="line">      printf(<span class="stringliteral">&quot;              comment=&#39;%s&#39;\n&quot;</span>, signal_comment);</div><div class="line">      printf(<span class="stringliteral">&quot;              encoding=&#39;%s&#39;\n&quot;</span>, sigEncToStr(sigEnc));</div><div class="line">      printf(<span class="stringliteral">&quot;              representation=&#39;%s&#39;\n&quot;</span>, sigRepToStr(sigType));</div><div class="line">      printf(<span class="stringliteral">&quot;              value min=%.02f, value max=%.02f\n&quot;</span>, minval, maxval);</div><div class="line">      printf(<span class="stringliteral">&quot;              scale faktor=%.02f, offset=%.02f\n&quot;</span>, factor, offset);</div><div class="line">      printf(<span class="stringliteral">&quot;              startbit=%d, length=%d\n&quot;</span>, startbit, length);</div><div class="line">      status = <a name="a48"></a><a class="code" href="group__kvadb__signals.html#ga98c181ec06d6975556d2f893ec353b90">kvaDbGetNextSignal</a> (mh, &amp;sh);</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a name="a49"></a><a class="code" href="group__kvadb__messages.html#ga0146dd4ddf2c39bfdc3b93c29fe85b32">kvaDbGetNextMsg</a> (dh, &amp;mh);</div><div class="line">  }</div><div class="line"></div><div class="line">  status = <a class="code" href="group__kvadb__database.html#ga08c85db8a33c4dcdb9d1114b72ab7c30">kvaDbClose</a> (dh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf (<span class="stringliteral">&quot;kvaDbClose failed: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line">  printf(<span class="stringliteral">&quot;\n\n&quot;</span>);</div><div class="line">  <span class="keywordflow">return</span> <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// Edit the new database by removing the first message and updating</span></div><div class="line"><span class="comment">// the scale factor for a signal in the second message.</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// -----------------------------------------------------------------------</span></div><div class="line"></div><div class="line"><a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> editDatabase (<span class="keywordtype">char</span>* filename) {</div><div class="line"></div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57">KvaDbStatus</a> status;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a0ab6b252bb2dbf1312bd48208954e67b">KvaDbHnd</a> dh=0;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#a561c9270625ed9b7a4bc32edaab72227">KvaDbMessageHnd</a> mh;</div><div class="line">  <a class="code" href="kva_db_lib_8h.html#aa41cb518eea5c637f18eda0affa4e011">KvaDbSignalHnd</a> sh;</div><div class="line"></div><div class="line">  <span class="comment">// Open a database handle</span></div><div class="line">  status = <a class="code" href="group__kvadb__database.html#gacbcd92e8da46f1b756c72d25ab92d240">kvaDbOpen</a> (&amp;dh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbOpen falied: %d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Load the database file</span></div><div class="line">  status = <a class="code" href="group__kvadb__database.html#gaadd6d76a4a37fce5dacddc973951e8c8">kvaDbReadFile</a> (dh, filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not load &#39;%s&#39;: %d\n&quot;</span>, filename, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Search for a message by indentifier</span></div><div class="line">  status = <a name="a50"></a><a class="code" href="group__kvadb__messages.html#ga732d691ed8ead650e4a49d18c8f7ffa2">kvaDbGetMsgById</a>(dh, 340, &amp;mh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not find the message with identifier &#39;340&#39;:%d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Delete all signals in this message</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#gaeec680d3d20bddb57dd09389faacba9e">kvaDbGetFirstSignal</a> (mh, &amp;sh);</div><div class="line">  <span class="keywordflow">while</span> (status == <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    status = <a name="a51"></a><a class="code" href="group__kvadb__signals.html#gac92ad44609f7e08b21b00c1517643e59">kvaDbDeleteSignal</a>(mh, sh);</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf(<span class="stringliteral">&quot;Could not delete a signal: %d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div><div class="line">    status = <a class="code" href="group__kvadb__signals.html#ga98c181ec06d6975556d2f893ec353b90">kvaDbGetNextSignal</a> (mh, &amp;sh);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Delete the message</span></div><div class="line">  status = <a name="a52"></a><a class="code" href="group__kvadb__messages.html#ga35653db199de9237996e708ef9cfd7c1">kvaDbDeleteMsg</a>(dh, mh);</div><div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">      printf(<span class="stringliteral">&quot;Could not delete the message with identifier &#39;340&#39;:%d\n&quot;</span>, status);</div><div class="line">      <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">  <span class="comment">// Search for a message by name</span></div><div class="line">  status = <a name="a53"></a><a class="code" href="group__kvadb__messages.html#ga9685fdb33257ac28e4cd989cfe8ca154">kvaDbGetMsgByName</a>(dh, <span class="stringliteral">&quot;TempMessage02&quot;</span>, &amp;mh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not find the message with name &#39;TempMessage02&#39;:%d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Search for a signal in this message</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga1f735b50e369c784901abc3ea436fba9">kvaDbGetSignalByName</a>(mh, <span class="stringliteral">&quot;T01&quot;</span>, &amp;sh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not find the signal with name &#39;T01&#39;:%d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Update the scaling</span></div><div class="line">  status = <a class="code" href="group__kvadb__signals.html#ga3a01b63f3b3a413d008bdcb85778034f">kvaDbSetSignalValueScaling</a>(sh, 0.04, 5);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;Could not change the scale factor for signal &#39;T01&#39;:%d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Save the modified database to file</span></div><div class="line">  status = <a class="code" href="group__kvadb__database.html#gabf1db33bc6778e2f77ab1b66e8f743e9">kvaDbWriteFile</a>(dh, filename);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbWriteFile failed:%d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Close and free allocated memory</span></div><div class="line">  status = <a class="code" href="group__kvadb__database.html#ga08c85db8a33c4dcdb9d1114b72ab7c30">kvaDbClose</a>(dh);</div><div class="line">  <span class="keywordflow">if</span> (status != <a class="code" href="kva_db_lib_8h.html#a2f504ec74e40048f49ed23d630528d57ad8a19899af8c1e42208a67afb572b2fc">kvaDbOK</a>) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvaDbClose falied:%d\n&quot;</span>, status);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">return</span> status;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer"> (canlib 5.38) Tue Feb 15 2022</li>
  </ul>
</div>
</body>
</html>
